<template>
  <div class="homedata">
    <div class="title">
      <div :style="{ background: porps.color }" class="fk"></div>
      <div class="pt">{{ porps.title }}</div>
    </div>
    <ul>
      <li v-for="(item, index) in list" :key="index" @click="routerLuck(item)">
        <img :src="item.backgroundImage" alt="" class="backgroundImage" />
        <img :src="item.image" alt="" class="image" />
        <div class="info">
          <span class="name">{{ item.name }}</span>
          <img :src="prices" alt="" class="imgpr" />
          <span class="price">{{ item.price }}</span>
        </div>
      </li>
    </ul>
  </div>
</template>
<script setup>
import { useRouter } from "vue-router";
import { defineProps, onMounted, reactive, toRefs } from "vue";
import { blindBox } from '../api/home.js'
const porps = defineProps({
  boxType: {
    type: Number,
    default: 0,
  },
  title: {
    type: String,
    default: "",
  },
  color: {
    type: String,
    default: "",
  },
});
const useData = reactive({
  list: [],
});
const router = useRouter()
const { list } = { ...toRefs(useData) };
const _blindBox = async () => {
  const { data } = await blindBox({ typeId: porps.boxType });
  list.value = data.content;
};
const routerLuck = (query) => {
  router.push({ 
    path: '/Luck',
    query: {
      id: query.id
    }
  })
}
onMounted(() => {
  _blindBox();
});
</script>
<style lang="less" scoped>
.title {
  color: #fff;
  margin-left: 35px;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  .fk {
    width: 9px;
    height: 27px;
    margin-right: 23px;
  }
  .pt {
    font-size: 28px;
  }
}
.homedata {
  background: #141a28;
  ul {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    text-align: center;
    li {
      position: relative;
      width: 50%;
      padding: 0 28px;
      box-sizing: border-box;
      .info {
        margin-bottom: 70px;
        margin-top: 24px;
        font-weight: 400;
        font-size: 24px;
        * {
          display: inline-block;
          vertical-align: middle;
        }
        .name {
          color: #ffffff;
          margin-right: 20px;
        }
        .price {
          color: #ffa32a;
        }
        .imgpr {
          width: 23px;
          height: 23px;
        }
      }
      img {
        margin: 0 auto;
        display: block;
      }
      .image {
        width: 314px;
        position: absolute;
        left: 50%;
        top: 0;
        margin-left: calc(-314px / 2);
        // height: 157px;
      }
      .backgroundImage {
        width: 276px;
        height: 245px;
      }
    }
  }
}
</style>
